﻿using PDFDesign.Model;

namespace PDFDesign.ViewModel
{
    public class TextStyleViewModel : BaseViewModel
    {
        public TextStyleViewModel(Textstyle textstyle)
        {
            Textstyle = textstyle;
            name = textstyle.Font.Name;
            size = textstyle.Font.Size;
            alignIndex = (int)textstyle.Align;
            vAlignIndex = (int)textstyle.VAlign;
            top = textstyle.Margins.Top;
            left = textstyle.Margins.Left;
            right = textstyle.Margins.Right;
            bottom = textstyle.Margins.Bottom;
        }

        public void Save()
        {
            Textstyle.Font.Name = name;
            Textstyle.Font.Size = size;
            Textstyle.Align = (Align)alignIndex;
            Textstyle.VAlign = (VAlign)vAlignIndex;
            Textstyle.Margins.Top = top;
            Textstyle.Margins.Left = left;
            Textstyle.Margins.Right = right;
            Textstyle.Margins.Bottom = bottom;
        }

        public Textstyle Textstyle { get; set; }

        private FontName name = FontName.normal;
        public FontName Name
        {
            get => name;
            set
            {
                name = value;
                OnPropertyChanged("Name");
            }
        }

        private int size = 12;
        public int Size
        {
            get => size; set
            {
                size = value;
                OnPropertyChanged("Size");
            }
        }

        private int alignIndex;
        public int AlignIndex
        {
            get => alignIndex;
            set
            {
                alignIndex = value;
                OnPropertyChanged("AlignIndex");
            }
        }

        private int vAlignIndex;
        public int VAlignIndex
        {
            get => vAlignIndex;
            set
            {
                vAlignIndex = value;
                OnPropertyChanged("VAlignIndex");
            }
        }

        private double top;
        public double Top
        {
            get => top;
            set
            {
                top = value;
                OnPropertyChanged("Top");
            }
        }

        private double left;
        public double Left
        {
            get => left;
            set
            {
                left = value;
                OnPropertyChanged("Left");
            }
        }

        private double bottom;
        public double Bottom
        {
            get => bottom;
            set
            {
                bottom = value;
                OnPropertyChanged("Bottom");
            }
        }

        private double right;
        public double Right
        {
            get => right;
            set
            {
                right = value;
                OnPropertyChanged("Right");
            }
        }
    }
}
